import 'package:finance_app/generated/json/base/json_convert_content.dart';
import 'package:finance_app/generated/json/base/json_field.dart';
import 'package:finance_app/src/entities/contribution_entity.dart';
import 'package:finance_app/src/entities/country_entity.dart';
import 'package:finance_app/src/entities/depreciation_entity.dart';
import 'package:finance_app/src/entities/employment_type_entity.dart';
import 'package:finance_app/src/entities/grant_entity.dart';
import 'package:finance_app/src/entities/leave_type_entity.dart';
import 'package:finance_app/src/entities/martial_status_entity.dart';
import 'package:finance_app/src/entities/pass_type_entity.dart';
import 'package:finance_app/src/entities/salary_period_entity.dart';
import 'package:finance_app/src/entities/setting_alerts_entity.dart';
import 'package:finance_app/src/entities/setting_asset_category_entity.dart';
import 'package:finance_app/src/entities/setting_language_entity.dart';
import 'package:finance_app/src/entities/setting_template_entity.dart';
import 'package:finance_app/src/entities/setting_template_item_entity.dart';

class SettingDataEntity with JsonConvert<SettingDataEntity> {
  @JSONField(name: "category_group")
  List<SettingDataCategoryGroup> categoryGroup;
  List<SettingDataCategory> category;
  List<SettingDataTax> tax;
  List<SettingDataCurrency> currency;
  @JSONField(name: "common_currency")
  List<SettingDataCurrency> commonCurrency;
  @JSONField(name: "payment_type")
  List<SettingDataPaymentType> paymentType;
  @JSONField(name: "unit_type")
  List<SettingDataUnitType> unitType;
  @JSONField(name: "paid_using")
  List<SettingDataPaidUsing> paidUsing;

  List<CountryEntity> country;

  @JSONField(name: "martial_status")
  List<MartialStatusEntity> martialStatus;

  @JSONField(name: "pass_type")
  List<PassTypeEntity> passType;

  @JSONField(name: "employment_type")
  List<EmploymentTypeEntity> employmentType;

  @JSONField(name: "salary_period")
  List<SalaryPeriodEntity> salaryPeriod;

  @JSONField(name: "leave_type")
  List<LeaveTypeEntity> leaveType;

  @JSONField(name: "depreciation_type")
  List<DepreciationEntity> depreciationType;

  List<ContributionEntity> contribution;

  @JSONField(name: "asset_category")
  List<SettingAssetCategoryEntity> assetCategory;

  List<SettingLanguageEntity> language;

  List<SettingTemplateItemEntity> template;

  List<SettingAlertsEntity> alerts;

  List<GrantEntity> grants;

}

class SettingDataCategoryGroup with JsonConvert<SettingDataCategoryGroup> {
  @JSONField(name: "data_type")
  String dataType;
  int id;
  String key;
  String name;
}

class SettingDataCategory with JsonConvert<SettingDataCategory> {
  @JSONField(name: "data_type")
  String dataType;
  int id;
  String key;
  String name;
  String type;
  @JSONField(name: "category_group")
  String categoryGroup;
  @JSONField(name: "is_recommended")
  int isRecommended;
}

class SettingDataTax with JsonConvert<SettingDataTax> {
  @JSONField(name: "data_type")
  String dataType;
  int id;
  String key;
  String name;
  int rate;
  int enabled;

  String get displayName => '$rate% $key';

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is SettingDataTax &&
          runtimeType == other.runtimeType &&
          dataType == other.dataType &&
          id == other.id &&
          key == other.key &&
          name == other.name &&
          rate == other.rate &&
          enabled == other.enabled;

  @override
  int get hashCode =>
      dataType.hashCode ^
      id.hashCode ^
      key.hashCode ^
      name.hashCode ^
      rate.hashCode ^
      enabled.hashCode;
}

class SettingDataCurrency with JsonConvert<SettingDataCurrency> {
  @JSONField(name: "data_type")
  String dataType;
  int id;
  String key;
  String name;
}

class SettingDataPaymentType with JsonConvert<SettingDataPaymentType> {
  @JSONField(name: "data_type")
  String dataType;
  int id;
  String key;
  String name;
}

class SettingDataUnitType with JsonConvert<SettingDataUnitType> {
  @JSONField(name: "data_type")
  String dataType;
  int id;
  String key;
  String name;
  @JSONField(name: "is_editable")
  int isEditable;
}

class SettingDataPaidUsing with JsonConvert<SettingDataPaidUsing> {
  @JSONField(name: "data_type")
  String dataType;
  int id;
  String key;
  String name;
}
